package cn.bone.server.demo.service;

/**
 * Created by superbone on 2017/4/23.
 */

import cn.bone.common.api.demo.request.DemoUserLoginRo;
import cn.bone.common.api.demo.response.DemoUserHomePageVo;
import cn.bone.common.api.demo.response.DemoUserLoginVo;
import cn.bone.common.api.demo.service.IUserService;
import cn.bone.common.http.CommonRequest;
import cn.bone.common.http.CommonResult;
import cn.bone.common.http.ResultFactory;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service;

/**
 * Created by superbone on 2017/4/21.
 */
@Service
public class UserServiceImpl implements IUserService {

    private Logger logger = LoggerFactory.getLogger(UserServiceImpl.class);

    /**
     * 测试用户登录
     * @param request
     * @return
     */
    public CommonResult<DemoUserLoginVo> login(CommonRequest<DemoUserLoginRo> request){

        DemoUserLoginRo ro = request.getParam();
        String username = ro.getUsername();
        String password = ro.getPassword();

        DemoUserLoginVo vo = new DemoUserLoginVo();
        vo.setUserId(1);
        vo.setUsername(username);

        logger.info("测试用户登录");

        return ResultFactory.ok(vo);
    }

    /**
     * 测试空参数
     * @param request
     * @return
     */
    public CommonResult<DemoUserHomePageVo> homePage(CommonRequest<Void> request){

        DemoUserHomePageVo vo = new DemoUserHomePageVo();
        vo.setHome("home");
        vo.setPage("page");
        logger.info("测试空参数");
        return ResultFactory.ok(vo);
    }
}
